#!/bin/bash

echo ""
echo "========================================"
echo "🔍 验证微信权限修复"
echo "========================================"
echo ""

echo "📋 检查 QUERY_ALL_PACKAGES 权限..."
if grep -q "QUERY_ALL_PACKAGES" android/app/src/main/AndroidManifest.xml; then
    echo "✅ 已找到 QUERY_ALL_PACKAGES 权限"
    grep "QUERY_ALL_PACKAGES" android/app/src/main/AndroidManifest.xml
else
    echo "❌ 未找到 QUERY_ALL_PACKAGES 权限"
fi
echo ""

echo "📋 检查 queries 中的微信声明..."
if grep -q "com.tencent.mm" android/app/src/main/AndroidManifest.xml; then
    echo "✅ 已找到微信包名声明"
    grep "com.tencent.mm" android/app/src/main/AndroidManifest.xml
else
    echo "❌ 未找到微信包名声明"
fi
echo ""

echo "========================================"
echo "💡 修复状态总结"
echo "========================================"
echo ""
echo "如果两项都显示 ✅，说明修复成功！"
echo ""
echo "下一步操作："
echo "1. 重新构建APK"
echo "   flutter clean"
echo "   flutter build apk --release"
echo ""
echo "2. 安装到手机测试"
echo "   flutter install"
echo ""
echo "3. 测试微信分享功能"
echo ""
echo "========================================"
echo ""

read -p "按回车键退出..."

